package com.tom.demo.valid.parentheses;

public class PalindromeTest {

    public static boolean isPalindrome(String s) {
        if (s == null) return false;

        String str = s.replaceAll("[^\\u4e00-\\u9fa5a-zA-Z0-9]+", "").toLowerCase();
        if (str.length() <= 1) return true;
        for (int i = 0; i < str.length() / 2; i++) {
            if (str.charAt(i) != str.charAt(str.length() - (i + 1))) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
//        System.out.println(isPalindrome("A man, a plan, a canal: Panama"));
//        System.out.println(isPalindrome("a."));
        System.out.println(isPalindrome("ab_a"));
    }
}
